# -*- coding: utf-8 -*-
import maya.cmds as cmds
import maya.mel as mel

references = cmds.file ( q=True, r=True )
top_nodes = cmds.ls ( assemblies=True )
for reference in references :
    if 'BG' in reference :
        filepath = cmds.referenceQuery ( reference, namespace=True, shortName=True )
        for tmp in top_nodes :
            if filepath in tmp :
                print ( tmp )
                cmds.setAttr ( tmp + ".useOutlinerColor", 1 )
                cmds.setAttr ( tmp + ".oclr", 1, 0, 1, type="float3" )
    if 'CH' in reference :
        filepath = cmds.referenceQuery ( reference, namespace=True, shortName=True )
        for tmp in top_nodes :
            if filepath in tmp :
                print ( tmp )
                cmds.setAttr ( tmp + ".useOutlinerColor", 1 )
                cmds.setAttr ( tmp + ".oclr", 0, 0, 1, type="float3" )
    if 'PROP' in reference :
        filepath = cmds.referenceQuery ( reference, namespace=True, shortName=True )
        for tmp in top_nodes :
            if filepath in tmp :
                print ( tmp )
                cmds.setAttr ( tmp + ".useOutlinerColor", 1 )
                cmds.setAttr ( tmp + ".oclr", 0, 1, 1, type="float3" )

